import logging
import time

import yaml

from page_object.base_page import BasePage
from page_object.guang_page import GuangPage
from resource.contact import *
from resource.path_info import *
from util.devices import *

"""
登录页面
"""
class LoginPage(GuangPage):


    def login(self, d, userPhone, userPassword):
        print("login")
        self.to_password_login(d)

        d.xpath(phoneInput_but_xpath).click()
        d(focused=True).send_keys(userPhone)
        d.xpath(loginPageTitle_but_xpath).click()

        d.xpath(passwordInput_but_xpath).click()
        d(focused=True).send_keys(userPassword)
        d.xpath(loginPageTitle_but_xpath).click()

        d.xpath(login_but_xpath).click()
        time.sleep(1)
        if d.xpath(privacy_confirm_but_xpath).exists:
            d.xpath(privacy_confirm_but_xpath).click()
            d.xpath(loginPageTitle_but_xpath).click()
            d.xpath(login_but_xpath).click()
        time.sleep(2)

    def to_password_login(self, d):
        if d.xpath(toLoginPwd_but_xpath).exists:
            d.xpath(toLoginPwd_but_xpath).click()







